<template>
	<div class="detailsworkTime-container" v-if="showDetailsWorkTime">
		<el-dialog title="详情" custom-class="detailsworkTime-dialog" :visible.sync="showDetailsWorkTime" width="45%" :before-close="closeDetailsWorkTime" append-to-body>
			<el-form :model="form" label-width="100px" label-position="left" :rules="rules" ref="">
				<el-form-item label="规则名称">
					<el-input v-model="form.detailName" disabled></el-input>
				</el-form-item>
				<div class="time">
					<ul>
						<li>时</li>
						<li>分</li>
						<li>秒</li>
					</ul>
					<ul>
						<li>时</li>
						<li>分</li>
						<li>秒</li>
					</ul>
				</div>
				<div class="detailsWorkTime-content">
					<div class="timeReg">
						<span>工作时间</span>
					</div>
					<div class="workTime" v-for="(item, index) in form.detailWorkTime" :key="index">
						<el-form-item label="" prop="workTime">
							<el-select v-model="item.startHour" placeholder="" disabled :popper-append-to-body="false">
								<el-option v-for="sItem in timeList" :key="sItem.value" :label="sItem.label" :value="sItem.value" visible-change="false"></el-option>
							</el-select>
							<span class="margin-left-10">：</span>
							<el-select v-model="item.startMinute" placeholder="" disabled style="margin-left: 20px" :popper-append-to-body="false">
								<el-option v-for="sItem in minuteList" :key="sItem.value" :label="sItem.label" :value="sItem.value"></el-option>
							</el-select>
							<span class="margin-left-10">：</span>
							<el-select v-model="item.startSecond" placeholder="" disabled style="margin-left: 30px" :popper-append-to-body="false">
								<el-option v-for="sItem in minuteList" :key="sItem.value" :label="sItem.label" :value="sItem.value"></el-option>
							</el-select>
							<span class="margin-left-20">—</span>
							<el-select v-model="item.endHour" placeholder="" disabled style="margin-left: 30px" :popper-append-to-body="false">
								<el-option v-for="sItem in timeList" :key="sItem.value" :label="sItem.label" :value="sItem.value"></el-option>
							</el-select>
							<span class="margin-left-10">：</span>
							<el-select v-model="item.endMinute" placeholder="" disabled style="margin-left: 25px" :popper-append-to-body="false">
								<el-option v-for="sItem in minuteList" :key="sItem.value" :label="sItem.label" :value="sItem.value"></el-option>
							</el-select>
							<span class="margin-left-10">：</span>
							<el-select v-model="item.endSecond" placeholder="" disabled style="margin-left: 25px" :popper-append-to-body="false">
								<el-option v-for="sItem in minuteList" :key="sItem.value" :label="sItem.label" :value="sItem.value"></el-option>
							</el-select>
						</el-form-item>
					</div>
				</div>
			</el-form>
		</el-dialog>
	</div>
</template>

<script>
import { mapState } from 'vuex';
export default {
	name: 'detailWorkTime',
	props: {
		showDetailsWorkTime: {
			type: Boolean,
			required: true,
			default: () => false
		}
	},
	data() {
		return {
			form: {
				detailName: '', //详情工作名称
				detailWorkTime: [] //详情工作时间
			}
		};
	},
	mounted() {
		let detailWorkTime = { startHour: '', startMinute: '', startSecond: '', endHour: '', endMinute: '', endSecond: '' };
		this.form.detailWorkTime.push(detailWorkTime);
		this.initData();
	},
	computed: {
		...mapState({
			detailWorkingTimeId: state => state.editWorkingTime.id,
			detailWorkingTimeName: state => state.editWorkingTime.name,
			detailWorkingTimeTimes: state => state.editWorkingTime.times
		})
	},
	methods: {
		initData() {
			let workingTimeName = JSON.parse(JSON.stringify(this.detailWorkingTimeName));
			this.form.detailName = workingTimeName;
			let workingTimeTimes = JSON.parse(JSON.stringify(this.detailWorkingTimeTimes));
			this.form.detailWorkTime = workingTimeTimes;
			console.log(workingTimeName);
		},
		closeDetailsWorkTime() {
			this.$emit('closeDetailsWorkTime');
		}
	}
};
</script>

<style scoped lang="less">
.detailsworkTime-dialog {
	display: flex;
	position: relative;
	.time {
		display: flex;
		padding: 0 65px;
		ul {
			display: flex;
			li {
				padding: 0 36px;
				font-size: 12px;
				font-family: PingFang SC;
				font-weight: 400;
				color: #666666;
			}
		}
	}
	.detailsWorkTime-content {
		margin-top: -20px;
	}
	.timeReg {
		position: relative;
		top: 30px;
		left: 0;
	}
	.workTime {
		.colon {
			width: 3px;
			height: 8px;
			font-size: 14px;
			font-family: PingFang SC;
			font-weight: 400;
			color: #666666;
		}
		.margin-left-10 {
			margin-left: 10px;
			font-family: PingFang SC;
			font-weight: 700;
			font-size: 12px;
			color: #666666;
		}
		.margin-left-20 {
			margin-left: 10px;
		}
	}
}
</style>

<style lang="less">
.detailsworkTime-dialog .el-dialog__body {
	border-bottom: 1px solid #eee;
	border-top: 1px solid #eee;
}
.detailsworkTime-dialog .el-input {
	input {
		width: 234px;
		height: 36px;
		margin-left: -20px;
	}
}
.workTime .el-icon-arrow-up:before {
	content: none;
}
.workTime .el-input__inner {
	padding: 0;
}
.workTime {
	input.el-input__inner {
		width: 48px;
		height: 32px;
	}
}
.workTime .el-select-dropdown__list {
	margin: 0 -3px;
}

.workTime .el-select > .el-select-dropdown {
	transform: translateX(-22px);
}
.workTime .el-input.is-disabled .el-input__inner {
	background-color: #fff;
	color: #666666;
}
</style>
